package com.hzj.controller;

import com.hzj.pojo.Department;
import com.hzj.pojo.HospitalInfo;
import com.hzj.pojo.HospitalSet;
import com.hzj.pojo.Schedule;
import com.hzj.service.HospitalService;
import com.hzj.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/platformapi/hosp/hospital")
@CrossOrigin
public class HospitalController {

    @Autowired
    HospitalService hs;

    @PostMapping("/{page}/{limit}")
    Result getPageList(@PathVariable Integer page, @PathVariable Integer limit, @RequestParam(required = false) String hostype, @RequestParam(required = false) String districtCode) {


        return hs.getPageList(page, limit, hostype, districtCode);
    }

    @PostMapping("/findByHosname/{hosname}")
    Result findByHosname(@PathVariable String hosname) {

        return hs.findByHosname(hosname);
    }

    @PostMapping("/{hoscode}")
    Result hospitalByHoscode(@PathVariable String hoscode) {

        return Result.ok(hs.hospitalByHoscode(hoscode));
    }

    @PostMapping("/department/{hoscode}")
    Result findDepartment(@PathVariable String hoscode) {

        return Result.ok(hs.findDepartment(hoscode));
    }

    @PostMapping("/auth/findScheduleList/{hoscode}/{depcode}/{workDate}")
    Result findScheduleList(@PathVariable String hoscode, @PathVariable Integer depcode, @PathVariable String workDate) {
        return hs.findScheduleList(hoscode, depcode, workDate);
    }

    @PostMapping("/auth/getBookingScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public Result getBookingScheduleRule(@PathVariable Integer page, @PathVariable Integer limit, @PathVariable String hoscode, @PathVariable Integer depcode) {
        return hs.getBookingScheduleRule(page, limit, hoscode, depcode);
    }

    @PostMapping("/auth/getSchedule/{id}")
    public Result getSchedule(@PathVariable Integer id) {
        Schedule schedule = hs.getSchedule(id);
        HospitalSet hospitalSet = hs.getHospitalSetByHoscode(schedule.getHoscode());
        Department department = hs.getDepartmentByCode(schedule.getDepcode());
        Map map=new HashMap();
        map.put("schedule",schedule);
        map.put("hospitalSet",hospitalSet);
        map.put("department",department);

//        System.out.println("/=====/>>"+schedule);
        return Result.ok(map);
    }



}
